<div id="player">
  <script type='text/javascript' src='/swfobject.js'></script>

  <div id='mediaspace'>This text will be replaced</div>

  <script type='text/javascript'>
    var so = new SWFObject('/player.swf','ply','480','360','9','#ffffff');
    so.addParam('allowfullscreen','true');
    so.addParam('allowscriptaccess','always');
    so.addParam('wmode','opaque');
    so.addVariable('file',"http://<%=request.host_with_port%>/movies/stream/<%= @movie.id%>.flv");
    so.write('mediaspace');
  </script>
</div>

<div id="div-comments">
  <div id="comments">
    Loading comments...
  </div>
  <p><div id="postResult"></div>
  <div id="new-comment">
  <% if current_user %>
<% comment = Comment.new %>
<% form_for comment, :url=>{:controller=>"comments",:action=>"xpost"} do |f| %>
  <p>
    <b><%= f.label :content, "New Comment" %></b><br />
    <%= f.text_area :content, :size=>"50x5" %>
    <%= f.hidden_field :movie_id, :value=>@movie.id %><br />
    <%= submit_tag "Post", :onclick=>"postComment();return false;" %>
  </p>
<% end %>

  <% else %>
    <hr>
    Please <b><%= link_to "login", "/login" %></b> to post a new comment.
  <% end %>
  </div></p>
</div>

<script type="text/javascript">
postComment = function(){
var content =  $('comment_content').value;
if(new RegExp(/^\s*$/).test(content))
{
  alert("评论不能为空！");
  return false;
}
<%= remote_function \
    :update => "postResult", \
    :method => "post", \
    :url =>{:controller=>"comments",:action=>"xpost"}, \
    :with => "\"comment[content]=\"+content+\"&comment[movie_id]=#{@movie.id}\"" %>
updateComments();
}// end of postComment

//-------------------------------------------
updateComments = function(){<%= remote_function :method => "get",
                    :url    => "/comments/movie/#{@movie.id}",
                    :update => "comments" %>
}// end of updateComments
updateComments();

//-------------------------------------------
<%= remote_function :method => "get",
    :url => "/movies/info/#{@movie.id}",
    :update => "ajaxCon" %>
</script>
